-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT improvements and fixes #2
Conversation
e10c385
to
8e3777c
Compare
@PaulG4H, if you want to test early :) I'm testing with the setup from https://github.com/rechrtb/Duet-Demo/tree/master/mqtt, and seems to work ok when following the README, but I'm still double checking the code if I miss some potential bugs. |
6b3f92e
to
0900ffe
Compare
src/Networking/MQTT/MqttClient.h
Outdated
|
||
uint32_t messageTimer; // General purpose variable for keeping track of queued messages timeout | ||
Mutex publishMutex; | ||
|
||
MqttClient *next; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what conditions can we have more than one MqttClient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case where more than one MqttClient instance is needed is for when there are multiple brokers - either on the same interface or on different interfaces.
Per our email conversation, only one broker on one interface needs to be supported for now. So I changed MqttClient to be a singleton. This is remnant of the old code I forgot to delete.
#define MQTT_PAL_MUTEX_LOCK(x) | ||
#define MQTT_PAL_MUTEX_INIT(x) | ||
#define MQTT_PAL_MUTEX_UNLOCK(x) | ||
typedef struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm that we need to use a mutex, i.e. there can be more than one task accessing those parts of the system that the mutex guards. Also, are we certain that no deadlock can occur?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mutex is for guarding resources between (1) the main task when it calls mqtt_publish
- when buffering the message for sending and (2) the network task when it calls mqtt_sync
- when moving data from mqtt buffer to socket buffer.
As to whether deadlocks can occur, one of the condition for it does not seem to be satisfied - circular wait. mqtt_sync
and mqtt_publish
only share 1 common mutex they are both attempting to lock; and mqtt_publish
itself only tries to attempt to lock 1 mutex, breaking the possibility of a circular wait chain from forming.
a9c67a5
to
3478a74
Compare
Further to my previous message, I see that the current API does support
starting at a specified channel when connecting to a specified SSID. See
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
.
…On Mon, 25 Sept 2023 at 08:39, rechrtb ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/Networking/MQTT/MqttClient.h
<#2 (comment)>:
>
uint32_t messageTimer; // General purpose variable for keeping track of queued messages timeout
- Mutex publishMutex;
MqttClient *next;
The case where more than one MqttClient instance is needed is for when
there are multiple brokers - either on the same interface or on different
interfaces.
Per our email conversation, only one broker on one interface needs to be
supported for now. So I changed MqttClient to be a singleton. This is
remnant of the old code I forgot to delete.
—
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUYI3FIQUHMRNCHJJ3NC73X4EYLJANCNFSM6AAAAAA4QNCYPQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
David Crocker, Duet3D Ltd.
|
d4893ad
to
ce4a6a8
Compare
@rechrtb sorry for the late reply, Many thank's for your work to bring mqtt native to RRF! I testet the current 3.5.0-rc.1+102 Version today, it works better but the Topic in M118 gets corrupted --> when I run: I have no clue why the topic is corrupted to only >k40<, instead of the full path >devices/rrf-k40/status< After further testing, the topic is ignored totaly, instead the machine Name is used. It seams that my ESP32 Firmware is not working correctly? |
Hi @PaulG4H, no worries. I tested sending I will have to ask where did you get the binary for the RRF version you tested? You might be testing one that don't have these changes yet, or at least the latest changes in this pull request. Can you try doing I'm not sure if you are able to build RRF with the changes in this pull request. If not, I can send you a build - though don't know the board you're using. Furthermore, you might be apprehensive of trusting some binary from some stranger online (rightfully so!). @dc42 can I share with @PaulG4H a built binary with this PR using the Duet3D Dropbox? |
@rechrtb I already post this issue in the RRF discord --> I use a SKR2 board with the binary created by GloomyAndy and his Version is not the latest. So I will wait for that. I also see in the official documentation the LWT config, this is so great either! When your changes are applied to the RRF binaries this opens a whole now world! Smarthome Integration without pooling, no matter if you use Home Assistant, IP Symcon, IO Broker, OpenHab or any other which is able to receive MQTT topics! Or switch a external relay from GCode (Tasmota or Shelly Device) directly over WiFi for example the Dust Collector for the CNC or the Chiller for the Laser... Many thanks for your time and effort! |
Unfortunately I don't have the build environment for RRF SKR setup. So if
you want to test these changes, you might want to ask around if someone can
do a build for you with the branch on this PR. Or, wait for this to get
merged and RRF SKR project to pick up the changes like you mentioned.
Great to hear about your excitement regarding this feature! Much
appreciated.
…On Sun, Oct 1, 2023, 18:31 PaulG4H ***@***.***> wrote:
@rechrtb <https://github.com/rechrtb> I already post this issue in the
RRF discord --> I use a SKR2 board with the binary created by GloomyAndy
and his Version is not the latest.
So I will wait for that.
You also see in the official documentation the LWT config, this is so
great!
When your changes are applied to the RRF binaries this opens a whole now
world!
Smarthome Integration without pooling, no matter if you use Home
Assistant, IP Symcon, IO Broker, OpenHab or any other which is able to
receive MQTT topics!
Or switch a external relay from GCode (Tasmota or Shelly Device) directly
over WiFi for example the Dust Collector for the CNC or the Chiller for the
Laser...
Many thanks for your time and effort!
—
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYN7X3RG4LDJHXJ5MFSDBPLX5EZ6FANCNFSM6AAAAAA4QNCYPQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@rechrtb please make that change and then merge this PR into your 3.5-dev branch; then let me know and I will merge your 3.5-dev branch into the master. |
This is moved to another repo
- Fix setting connect flags related to LWT - Display debug message when changing subscription QOS - Replace max QOS argument
Since MQTT client is implemented as a singleton for now, remove code related to partially handling multiple instances.
Closing due to mistake in target branch. See Duet3D#923 instead. |
Follow up to Duet3D#589.
Q
toO
inM586.4
M586.4
.M118
via parameterT
. QOS, retain and duplicate flags can be optionally specified viaQ
,R
andD
inM118
Q
andR
inM586.4
.Closes Duet3D#880.